<?php
namespace app\admin\controller;

\think\Loader::import('controller/Controller', \think\Config::get('traits_path') , EXT);

use app\admin\Controller;
use think\Db;
class MfwOrder extends Controller
{
    use \app\admin\traits\controller\Controller;
    // 方法黑名单
    protected static $blacklist = [];

    /**
     * 首页
     * @return mixed
     */
    public function index()
    {
        $data = input();
        if($this::$isdelete){
            $map['mo.isdelete']=1;
        }
        if ($data['order_id']) {
            $map['mo.order_id'] =array('like',"%{$data['order_id']}%") ;
        }

        if($data['phone']){
            $map['mbp.phone'] =array('like',"%{$data['phone']}%") ;
        }
        if($data['booking_people_name']){
            $map['o.booking_people_name'] =array('like',"%{$data['booking_people_name']}%") ;
        }

        if($data['go_date']){
            $map['mo.go_date'] = array("between",[strtotime($data['go_date']." 00:00:00"),strtotime($data['go_date']." 23:59:59")]);

        }
        $listRows = $this->request->param('numPerPage') ?: config("paginate.list_rows");

        $list = Db::name('mfw_order')
            ->alias('mo')
            ->join("tp_mfw_booking_people mbp" ,"mo.mfw_booking_people_id=mbp.id","left")
            ->join("tp_mfw_sku sku" ,"mo.sku_id=sku.sku_id","left")
            ->where($map)
            ->order('mo.id', 'desc')
            ->field("mo.*,mbp.name,mbp.uid,mbp.phone,sku.sku_name")
            ->order('mo.update_time','desc')
            ->paginate($listRows, false, ['query' => $this->request->get()]);

        // 模板赋值显示
        $this->view->assign('list', $list);
        $this->view->assign("count", $list->total());
        $this->view->assign("page", $list->render());
        $this->view->assign('numPerPage', $list->listRows());
        return $this->view->fetch();
    }
}
